import request from '../utils/wxRequest';
export const baseUrl = 'https://mp.oppoedu.com';

// 获取AccessToken的登录接口
export const loginApi = async function(data) {
  const res = await request.post(`${baseUrl}/oauth2/wechat`, data);
  return res;
};

// 获取用户信息
export const getUserInfoApi = function() {
  return request.get(`${baseUrl}/passport/mine`);
};

// 修改用户信息
export const changeUserInfoApi = function(data) {
  return request.post(`${baseUrl}/user/profile/update`, data);
};

// 获取分类列表
export const getCategoryListApi = async function() {
  const res = await request.get(`${baseUrl}/course/category/index`);
  return res;
};

// 首页配置接口
export const getHomeConfigApi = async function() {
  return request.get(`${baseUrl}/site/home`);
};

// 首页课程列表接口
export const getHomeCourseApi = function(areaCode) {
  return request.get(`${baseUrl}/course?area=${areaCode}`);
};

// 分类课程检索接口
export const getCourseSearchApi = function(page, data) {
  return request.get(`${baseUrl}/course/search/index?page=${page}`, data);
};

// 发布活动接口
export const publishCourseApi = function(data) {
  return request.post(`${baseUrl}/course/apply/create`, data);
};

// 获取短信验证码接口
export const getSMSCode = function(data) {
  return request.post(`${baseUrl}/sms/captcha`, data);
};

// 学校列表接口
export const getSchoolListApi = function(page, data, areaCode) {
  return request.get(`${baseUrl}/school?page=${page}&area=${areaCode}`, data);
};

// 教师列表接口
export const getTeacherListApi = function(page, data) {
  return request.get(`${baseUrl}/educater/teacher?page=${page}`, data);
};

// 获取学校详情接口
export const getSchoolInfoApi = function(id) {
  return request.get(`${baseUrl}/h5/school/${id}`);
};

// 获取学校精品课程接口
export const getSchoolCourseApi = function(page, id) {
  return request.get(`${baseUrl}/h5/school/course?id=${id}&page=${page}`);
};

// 关注接口
export const followApi = function(data) {
  return request.post(`${baseUrl}/h5/follow/attention`, data);
};

// 获取教师详情接口
export const getTeacherInfoApi = function(id) {
  return request.get(`${baseUrl}/educater/teacher/${id}`);
};

// 获取教师课程列表接口
export const getTeacherCourseApi = function(page, id) {
  return request.get(`${baseUrl}/educater/teacher/course?id=${id}&page=${page}`);
};

// 获取课程详情接口
export const getCourseDetail = function(id) {
  return request.get(`${baseUrl}/h5/course/${id}`);
};

// 获取朋友圈列表接口
export const getDiscoverList = function(page, areaCode) {
  return request.get(`${baseUrl}/dynamic?page=${page}&area=${areaCode}`);
};

// 发现点赞接口
export const discoverLikeApi = function(data) {
  return request.post(`${baseUrl}/dynamic/extend/like`, data);
};

// 发现内容评论接口
export const discoverCommentApi = function(data) {
  return request.post(`${baseUrl}/dynamic/comment/create`, data);
};

// 浏览历史记录
export const userHistoryApi = function(page) {
  return request.get(`${baseUrl}/user/history?page=${page}`);
};

// 我的课程
export const myclassListApi = function(page) {
  return request.get(`${baseUrl}/user/course?page=${page}`);
};

// 关注学校列表
export const getFollowSchoolList = function(page) {
  return request.get(`${baseUrl}/user/follow/school?page=${page}`);
};

// 关注老师列表
export const getFollowTeacherList = function(page) {
  return request.get(`${baseUrl}/user/follow/teacher?page=${page}`);
};

// 帮助列表
export const getHelpListApi = function() {
  return request.get(`${baseUrl}/h5/help`);
};

// 帮助详情
export const getHelpDetailApi = function(id) {
  return request.get(`${baseUrl}/h5/help/${id}`);
};

// 绑定手机号接口
export const bindMobileApi = function(data) {
  return request.post(`${baseUrl}/passport/bind-mobile`, data);
};

// 获取支付参数接口
export const orderCreateApi = function(data) {
  return request.post(`${baseUrl}/course/order/create`, data);
};
